package com.sanploy.server.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * Created by Administrator on 2017/6/20.
 */
@Component
public class WechatTask {

    @Autowired WechatUtil wechatUtil;

    @Scheduled(cron = "0 0/20 * * * ?") // 每1800秒执行一次
    public void scheduler() {
        try {
            WechatToken wechatToken = wechatUtil.getAccessToken();
            if (wechatToken!=null){
                System.out.println(System.currentTimeMillis()+" : "+wechatToken.getAccess_token());
            }else {
                System.out.println("获取失败");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
